package com.liufei.controller;

import com.liufei.consumer.KafkaConsumer;
import com.liufei.producer.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 刘飞
 * @time 2021/4/20
 */
@RestController
@RequestMapping("kafka")
public class KafkaController {
    @Autowired
    private KafkaConsumer consumer;
    @Autowired
    private KafkaProducer producer;

    @GetMapping("sendMessage")
    public String producerMessage(String name){
        Map<String,String> map = new HashMap();
        map.put("name",name);
        producer.send(map);
        return "发送成功";
    }

}
